<template>
  <div>
    <div class="mui-numbox" data-numbox-min='1' :data-numbox-max="max">
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" value="1" @change="countedChange" ref="numberBox"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
  </div>
</template>

<script>
// 导入mui'的js组件
import mui from '../../lib/mui/js/mui.min.js'
export default {

  data () {
    return {
    }
  },

  methods: {
    countedChange(){
      // console.log(this.$refs.numberBox.value);
    //  const a = document.getElementById('test').value;
    //  console.log(a);
     this.$emit("getcounted", parseInt(this.$refs.numberBox.value));
    }
  },

  created () {
  },
  mounted () {
    mui('.mui-numbox').numbox();
    console.log(this.max);
    
  },
  watch: {
    max: function(newVal, oldVal){
      //mui组件提供的方法
      mui(".mui-numbox").numbox().setOption("max", newVal);
    }
  },
  props: ["max"]
}
</script>

<style lang='less'>

</style>
